package com.jbm.jbmsupplier.zp.adapters;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jbm.jbmsupplier.R;
import com.jbm.jbmsupplier.zp.entity.PullMessage;


/**
 * Created by donar_work on 2017/4/24.
 */

public class Contacct_Info_ListAdapter extends BaseAdapter {
    private Context context;
    private PullMessage pullMessage;
    public Contacct_Info_ListAdapter(Context context, PullMessage pullMessage){
        this.context = context;
        this.pullMessage = pullMessage;
    }
    @Override
    public int getCount() {
        return pullMessage.getCa().length;
    }

    @Override
    public Object getItem(int position) {
        return pullMessage.getCa()[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null){
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.list_contact_info_item,null);
            viewHolder.tv_lcii_ca = (TextView) convertView.findViewById(R.id.tv_lcii_ca);
            viewHolder.tv_lcii_mobile = (TextView) convertView.findViewById(R.id.tv_lcii_mobile);

            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tv_lcii_ca.setText(pullMessage.getCa()[position].gi_text);
        viewHolder.tv_lcii_mobile.setText(pullMessage.getCa()[position].mobile);
        return convertView;
    }
    class ViewHolder{
        public TextView tv_lcii_ca;
        public TextView tv_lcii_mobile;
    }
}
